"use strict";
classes.sprites.BackgroundManager = function() {
	return {
	    height : 670,
	    width: 1000,
	    sprites: null,
	    count: 0,
	    lastX: 0,
	    init : function() {
	        
	        var sprite1 = new cc.Sprite();
	        sprite1.initWithFile("res/background.png");
	        sprite1.setPosition(new cc.Point(this.lastX + this.width / 2, app
	                .getWindowSize().height / 2));

	        var sprite2 = new cc.Sprite();
	        sprite2.initWithFile("res/background.png");
	        sprite2.setPosition(new cc.Point(this.lastX + this.width * (3 / 2), app
	                .getWindowSize().height / 2));

	        this.sprites = new Array(sprite1, sprite2);
	    },
	    update: function(xPos) {
	    	if(xPos>this.lastX+1500) {
	    		this.lastX+=1000;
	    		this.sprites[(this.count++)%2].setPosition(new cc.Point(this.lastX + this.width * (3 / 2), app
	                .getWindowSize().height / 2));
	    	} else if(xPos<this.lastX+500) {
	    		this.lastX-=1000;
	    		this.sprites[(++this.count)%2].setPosition(new cc.Point(this.lastX + this.width * (1 / 2), app
	                .getWindowSize().height / 2));
	    	}
	    }
	};
};
